package com.supermarket.controller;

import com.supermarket.model.Fruit;
import com.supermarket.service.SettleAccountsService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.math.BigDecimal;
import java.util.List;

@Controller
@RequestMapping("/api/fruit")
public class SellFruitController {

    @Resource
    private SettleAccountsService settleAccountsService;

    /*
     * 根据传进来的水果计算价格
     */
    @GetMapping("sell")
    public BigDecimal calculatePrice(List<Fruit> fruitList) {
        return settleAccountsService.countMoney(fruitList, true);
    }
}
